# 学生信息管理系统 PyCharm
# main xf
# 2025.07.15 星期二 13:30
# from ___gxf_tool_code import 
# SPT2505

from fastapi import FastAPI
from tortoise.contrib.fastapi import register_tortoise
import uvicorn

from apps.students.urls import students
from apps.teachers.urls import teachers
from settings import TORTOISE_ORM
from fastapi.middleware.cors import CORSMiddleware


app = FastAPI()

app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],  # 允许的前端地址
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)


register_tortoise(
    app,
    config=TORTOISE_ORM,
    generate_schemas=True,
)

app.include_router(students,prefix='/stu',tags=['学生管理'])
app.include_router(teachers,prefix='/teacher',tags=['教师管理'])


if __name__ == '__main__':
    uvicorn.run("main:app", host="127.0.0.1", port=8000, reload=True)